<template>
  <div class="hello">
    <!-- 显示区域 -->
    <div 
      v-if="inputText"
      class="display-box"
    >
      {{ inputText }}
    </div>
    <!-- 清空按钮 -->
    <button 
      @click="handleClear"
      class="clear-btn"
    >
      清空
    </button>
  </div>
</template>

<script>
export default {
  name: 'HelloWorld',
  props: {
    inputText: {
      type: String,
      default: ''
    }
  },
  methods: {
    handleClear() {
      this.$emit('clear');
    }
  }
}
</script>

<style scoped>
.hello {
  text-align: center;
  margin-top: 60px;
}
.clear-btn {
  padding: 8px 20px;
  background-color: #42b983;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  margin-top: 10px;
}
.clear-btn:hover {
  background-color: #3aa876;
}
.display-box {
  padding: 20px;
  margin: 10px auto;
  width: 300px;
  min-height: 50px;
  text-align: left;
}
</style>
